#!/usr/bin/env perl
use strict;
use warnings;

open (IN, "< search.txt") or die;
my @info = <IN>;
close (IN);
open (IN, "< ../list/list.txt") or die;
foreach (<IN>) {
    my ($id, $name, $class) = split m/\s+/;
    foreach (@info) {
        if ($_ =~ $name or $name =~ $_) {
            print "$id $class $info[0]";
            last;
        }
    }
}
close (IN);